package com.aepryus.loom;

import java.util.*;

public class ValidationException extends Exception {
	private Map map;
	private List<Problem> problems;
	private Map<String,Problem> lookup;

	public ValidationException (Map map) {
		this.map = map;
		problems = new Vector<Problem>();
		lookup = new HashMap<String,Problem>();
	}
	public ValidationException (String problem) {
		problems = new Vector<Problem>();
		lookup = new HashMap<String,Problem>();
		addProblem(new Problem(null,problem));
	}

	public void setMap (Map map) {this.map = map;}
	public Map getMap () {return map;}

	public void addProblem (Problem problem) {
		problems.add(problem);
		lookup.put(problem.getField(),problem);
	}
	public Problem getProblem (int i) {return problems.get(i);}
	public Problem getProblem (String name) {return lookup.get(name);}
	public int problemCount () {return problems.size();}
}

